﻿namespace System.Data.Entity.Utilities
{
    using System;
    using System.Data.Entity.Core.Metadata.Edm;
    using System.Reflection;

    internal static class EdmModelExtensions
    {
        #region Fields

        private readonly static Type _edmModelExtensions = Utilities.GetReferencedType(Utilities.assemblyEF,
            "System.Data.Entity.ModelConfiguration.Edm.EdmModelExtensions");

        private readonly static MethodInfo _edmModelExtensions_AddFunction = _edmModelExtensions
            .GetMethod("AddFunction", BindingFlags.Static | BindingFlags.Public);

        #endregion

        internal static EdmFunction AddFunction(this EdmModel database, string name, EdmFunctionPayload functionPayload)
        {
            return (EdmFunction)_edmModelExtensions_AddFunction.Invoke(null, new object[] { database, name, functionPayload });
        }
    }
}
